// 显示 Toast 消息函数
function showToast(message, type = 'info') {
    const toastContainer = document.getElementById('toastContainer');
    const toastId = 'toast_' + Date.now();

    const toastHtml = `
        <div class="toast ${type}" role="alert" aria-live="assertive" aria-atomic="true" id="${toastId}">
            <div class="toast-header">
                <strong class="me-auto">
                    ${type === 'success' ? '成功' : ''}
                    ${type === 'error' ? '错误' : ''}
                    ${type === 'warning' ? '警告' : ''}
                    ${type === 'info' ? '信息' : ''}
                </strong>
                <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
            </div>
            <div class="toast-body">
                ${message}
            </div>
        </div>
    `;

    toastContainer.insertAdjacentHTML('beforeend', toastHtml);

    const toastEl = document.getElementById(toastId);
    const toast = new bootstrap.Toast(toastEl, {
        delay: 3000
    });

    toast.show();

    // Toast 隐藏后自动移除
    toastEl.addEventListener('hidden.bs.toast', function () {
        toastEl.remove();
    });
}